<?php
declare (strict_types=1);

namespace Plugin\Organization\Model;

use Hyperf\Database\Model\SoftDeletes;
use Mine\MineModel;

class RdOrganizeArea extends MineModel
{
    use SoftDeletes;
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_organize_area';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'proj_line_id', 'name', 'abbr', 'addr', 'lat', 'lng', 'sort', 'code', 'status', 'created_by', 'updated_by', 'created_at', 'updated_at', 'deleted_at', 'remark', 'abstract', 'zone_id'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'proj_line_id' => 'integer',
        'zone_id' => 'integer',
        'status' => 'integer',
        'sort' => 'integer',
        'lat' => 'decimal:6',
        'lng' => 'decimal:6',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'deleted_at' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];

    /**
     * 关联项目线
     */
    public function projLine()
    {
        return $this->belongsTo(RdOrganizeProjLine::class, 'proj_line_id');
    }

    /**
     * 关联站点
     */
    public function stands()
    {
        return $this->hasMany(RdOrganizeAreaStand::class, 'area_id');
    }
}